package com.yiwyn.ood.capr;

public class CAPRGoodDemo {

    public static void main(String[] args) {

        Car car = new Car(new RedColor(), new EleEnergy());

        car.carInfo();

    }

    /**
     * 车辆类
     */
    static class Car {

        private final Color color;

        private final Energy energy;

        public Car(Color color, Energy energy) {
            this.color = color;
            this.energy = energy;
        }

        public void carInfo() {
            System.out.println("一个" + color.color() + energy.energy() + "车");
        }
    }

    // 颜色信息
    interface Color {
        String color();
    }

    // 能源信息
    interface Energy {
        String energy();
    }

    // 电动
    static class EleEnergy implements Energy {
        @Override
        public String energy() {
            return "Ele";
        }
    }

    // 红色
    static class RedColor implements Color {

        @Override
        public String color() {
            return "red";
        }
    }


}
